﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Mindfor.Web.Routing
{
	/// <summary>
	/// Defines method that works with routes.
	/// </summary>
	public static class RouteHelper
	{
		/// <summary>
		/// Combines 2 routes.
		/// </summary>
		/// <param name="routeParts">Route parts to merge.</param>
		/// <returns>Combined route.</returns>
		public static string Combine(params string[] routeParts)
		{
			StringBuilder sb = new StringBuilder();
			foreach (string part in routeParts)
			{
				if (part != null)
				{
					string p = part.Trim('/');
					if (p != "")
					{
						if (sb.Length > 0)
							sb.Append('/');
						sb.Append(p);
					}
				}
			}
			return sb.ToString();
		}
	}
}
